﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace YXShop.Web.membercenter.shop.shop_info
{
    public partial class shop_bank_list : System.Web.UI.Page
    {
        YXShop.BLL.SystemInfo.BankAccount bankBll = new YXShop.BLL.SystemInfo.BankAccount();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
                if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("id") != "")
                {
                    string types = Request["Option"].Trim();
                    string id = ChangeHope.WebPage.PageRequest.GetFormString("id");
                    if (types == "del")
                    {
                        bankBll.Delete(Convert.ToInt32(id));
                    }
                    if (types == "delAll")
                    {
                        bankBll.DeleteAll(id);
                    }
                    Response.End();
                    return;
                }
                this.litBank.Text = GetList();
            }

        }

        #region 获取TABLE
        //绑定table
        public string GetList()
        {
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            ChangeHope.DataBase.DataByPage dataPage = bankBll.GetList(" [order by] bank_ordernum DESC ", 20, " and bank_putoutID=" + Session["MemberID"].ToString());
            table.AddHeadCol("", "选择");
            table.AddHeadCol("", "Logo");
            table.AddHeadCol("", "帐户名称");
            table.AddHeadCol("", "开户行");
            table.AddHeadCol("", "帐户");
            table.AddHeadCol("", "权重");
            table.AddHeadCol("", "状态");
            table.AddHeadCol("", "常规操作");
            table.AddRow();
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            if (dataPage.DataReader != null)
            {
                while (dataPage.DataReader.Read())
                {
                    table.AddCol("<input id=\"cbTm\"  type=\"checkbox\" value=" + dataPage.DataReader["bank_id"] + " />");
                    table.AddCol("<img src='" +sp.DummyPaht+sp.WebSiteTemplatePath+ dataPage.DataReader["bank_icon"] + "' width=\"100\" height=\"48\"  />");
                    table.AddCol(dataPage.DataReader["bank_name"].ToString());
                    table.AddCol(dataPage.DataReader["bank_bankac"].ToString());
                    table.AddCol(dataPage.DataReader["bank_account"].ToString());
                    table.AddCol(dataPage.DataReader["bank_ordernum"].ToString());
                    table.AddCol(dataPage.DataReader["bank_putout"].ToString() == "1" ? "禁用" : "默认");
                    string url = YXShop.TemplateAction.Common.UrlStr("shop_bank_edit", "Bank_ID=" + dataPage.DataReader["bank_id"], "membercenter/shop/shop_info/");
                    table.AddCol("<a href='"+url+"'>编辑</a>  <a href=\"#\" onclick='Del(" + dataPage.DataReader["bank_id"] + ")'> 删除</a>");
                    table.AddRow();
                }
            }
            string view = table.GetTable() + dataPage.ReceptionToolBar;
            dataPage.Dispose();
            dataPage = null;
            return view;
        }
        #endregion    

        protected void linkSarch_Click(object sender, EventArgs e)
        {
            this.litBank.Text = GetList();
        }
       
    }
}
